package com.kelvem.saas.workbanch.ontology.order.event;

import com.kelvem.saas.workbanch.fsm.anno.Fsm;
import com.kelvem.saas.workbanch.fsm.anno.event.RegisterEvent;
import com.kelvem.saas.workbanch.fsm.anno.state.EventState;
import com.kelvem.saas.workbanch.fsm.anno.state.EventStateGroup;
import com.kelvem.saas.workbanch.ontology.order.model.OrderItemEntity;
import com.kelvem.saas.workbanch.ontology.order.model.OrdersEntity;
import com.kelvem.saas.workbanch.ontology.order.request.OrderItemReq;
import lombok.extern.slf4j.Slf4j;

/**
 * @author kelvem
 */
@Slf4j
@Fsm(entityClazz= OrderItemEntity.class, parentEntityClazz = OrdersEntity.class)
// 正常状态
@EventState(stateCode ="start", stateName ="起始", type="normal", start=1, timeout=600)
@EventState(stateCode ="pending", stateName ="待收款")
@EventState(stateCode ="payment", stateName ="已支付")
@EventState(stateCode ="confirm", stateName ="确认收款")
@EventState(stateCode ="matched", stateName ="已配货")
@EventState(stateCode ="send_to_wh", stateName ="发送库房")
@EventState(stateCode ="shipped", stateName ="已发货")
@EventState(stateCode ="received", stateName ="已收货")
// 异常状态
@EventState(stateCode ="cancel", stateName ="已取消", type="abnormal", end=1)
@EventState(stateCode ="returned", stateName ="已退货", type="abnormal", end=1)
// 正常状态组
// 异常状态组
@EventStateGroup(groupCode ="cancel_able", groupName ="可取消", states={"start", "pending"})
public class OrderItemEvent {
    
    @RegisterEvent(eventCode ="OrderItem.create", eventName="创建订单商品", srcState="start", dstState="pending")
    public void create(OrderItemReq OrderItemReq) {
        // do nothing
        log.info("create method do nothing");
    }
    
    @RegisterEvent(eventCode = "OrderItem.ship", eventName="订单商品发货", srcState="pending", dstState="shipped")
    public void ship(Long orderItemId) {
        // do nothing
        log.info("ship method do nothing");
    }
    
    @RegisterEvent(eventCode = "OrderItem.cancel", eventName="取消订单商品", srcState="cancel_able", dstState="cancel")
    public void cancel(Long orderItemId) {
        // do nothing
        log.info("cancel method do nothing");
    }
}
